Skip to content

fix(ui): reconnect event streams that stop delivering data - #5995

Merged
SteKoe merged 1 commit into
masterfrom
fix/sse-heartbeat-watchdog
Nov 28, 2026
Merged

SteKoe merged 1 commit into
masterfrom
fix/sse-heartbeat-watchdog

Conversation

@SteKoe

@SteKoe SteKoe commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

The server sends a :ping comment every 10 seconds on /applications and /instances/events. The browser's native EventSource never exposes comments, and the UI only reconnects after an error. If a NAT, firewall or route drops an idle connection without closing it, the UI gets neither data nor an error, and keeps showing the last state it saw until the page is reloaded.

Use event-source-polyfill (already a dependency, so far only loaded when EventSource is missing) for all event streams, with a heartbeatTimeout of 30 seconds. It counts comments as activity, aborts the request and reports an error when nothing arrives within the timeout, and the existing reconnect in ApplicationStore takes over (5 second delay). The timeout tolerates two missed pings.

The journal did not reconnect at all, it only showed an error. It now reconnects as well, and reloads the events first, so events from the outage are not lost.

utils/eventsource-polyfill.ts is replaced by utils/eventsource.ts.

How I tested this

Reproduced with a three node Hazelcast cluster behind Eureka, a browser that stays open, and a small TCP forwarder that silently stalls SSE connections (no close, no error):

UI after the instance is back (API says UP)
master still OFFLINE after more than 100 s, a fresh browser shows UP
this change UP again after about 30 s, application list and detail page

New specs fail without the change: utils/eventsource.spec.ts, services/eventstream.spec.ts, and two cases in views/journal/index.spec.ts. The whole UI suite passes (632 tests), as do lint and prettier.

Also checked with a plain server: the polyfill sends cookies like the native EventSource, and handles a Basic auth challenge.

What this does not show

  • It fixes the stale UI I could reproduce. I do not know whether it is what Bug: OFFLINE applications wont' recover #5960 reports, there is no confirmation from the reporter yet. I could not reproduce a stuck OFFLINE status in the backend (Hazelcast, Eureka and self registration, many failure scenarios on 4.1.5). If the UI is also wrong after a browser reload, this change does not help.
  • The Playwright e2e suite, Firefox and Safari were not run.
  • The browser now always uses the polyfill (fetch based) instead of the native EventSource. The polyfill logs a console.error when it times out.
  • The 30 second timeout is a choice, not a measured value.

@SteKoe
SteKoe marked this pull request as ready for review November 27, 2026 14:25
@SteKoe
SteKoe requested a review from a team as a code owner November 27, 2026 14:25
@SteKoe
SteKoe force-pushed the fix/sse-heartbeat-watchdog branch from 4a242aa to 30e4c0b Compare November 28, 2026 13:24
@SteKoe
SteKoe enabled auto-merge (squash) November 28, 2026 13:24
@SteKoe
SteKoe merged commit 2bd0982 into master Nov 28, 2026
2 checks passed
@SteKoe
SteKoe deleted the fix/sse-heartbeat-watchdog branch November 28, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant